In [19]:
require(rgdal)
require(ggplot2)
library(devtools)
library(sf)
library(tidyverse)
library(readxl)
library(sf)
library(fs)
library(magrittr)
library(leaflet)
library(leaflet.extras)
library(readr)

#Animal data
animal_data <- read_csv('dangerous_species.csv')
animal_df_all <- data.frame(animal_data)
animal_df <-animal_df_all[animal_df_all[, "Common_Name"] == "Bull Ant",]

#unzip(zipfile = "SDM843965.zip", 
#      exdir = 'PARKRES')
#parkres_shp <- readOGR(dsn = "PARKRES/ll_gda94/sde_shape/whole/VIC/CROWNLAND/layer", layer = "parkres")
parkres_shp <- readOGR(dsn = "layer", layer = "parkres")

# keeping only national parks

national_shp = subset(parkres_shp, str_detect(NAME, "National"))


anglerIcon1 <- makeIcon(
  iconUrl = "https://www.flaticon.com/svg/vstatic/svg/4433/4433047.svg?token=exp=1617229155~hmac=c5d16a1f20784de52d4d096619d2a681",
  iconWidth = 12, iconHeight = 12,
  iconAnchorX = 22, iconAnchorY = 94,
  
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)



anglerIcon2 <- makeIcon(
  iconUrl = "ant.png",
  iconWidth = 10, iconHeight = 10,
  iconAnchorX = 22, iconAnchorY = 94,
  
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)




pal <- colorFactor(
  palette = palette(rainbow(63)),
  domain = national_shp$NAME
)

leaflet() %>%
  addProviderTiles("Stamen.Terrain") %>%
  setView(144.2794, -36.7570, zoom = 7) %>%
  addPolygons(data = national_shp,color = "#444444", weight = 1, smoothFactor = 0.5,
              opacity = 1.0, fillOpacity = 0.5,
              fillColor = ~pal(NAME),
              highlightOptions = highlightOptions(color = "#888", weight = 2,
                                                  bringToFront = TRUE),
              label = national_shp$NAME,
              labelOptions = labelOptions(
                style = list("font-weight" = "normal", padding = "3px 8px"),
                textsize = "15px",
                direction = "auto"))%>%
  
  addMarkers(data = animal_df,~decimalLongitude,~decimalLatitude, label = ~Common_Name,icon = anglerIcon2,
             #popup = paste("<b>Hospital name:</b>", hospital$Name, "<br>",
             #              "<b>Hospital address:</b>", hospital$Address),
             #              clusterOptions = markerClusterOptions(),
             labelOptions = labelOptions(noHide = FALSE, direction = "left",textsize='8px',
                                         style=list(
                                           'color'= "black",
                                           'font-family'= 'serif',
                                           'font-style'= 'italic',
                                           'box-shadow' = '3px 3px rgba(0,0,0,0.25)',
                                           'font-size' = '15px',
                                           'border-color' = 'rgba(0,0,0,0.5)'
                                         ))
  )
Warning message:
"Duplicated column names deduplicated: 'verbatimLatitude' => 'verbatimLatitude_1' [58], 'verbatimLongitude' => 'verbatimLongitude_1' [60], 'verbatimCoordinateSystem' => 'verbatimCoordinateSystem_1' [62], 'scientificName' => 'scientificName_1' [80]"Parsed with column specification:
cols(
  .default = col_character(),
  `dcterms:bibliographicCitation` = col_logical(),
  individualCount = col_double(),
  year = col_double(),
  month = col_double(),
  day = col_double(),
  waterBody = col_logical(),
  islandGroup = col_logical(),
  island = col_logical(),
  minimumElevationInMeters = col_double(),
  maximumElevationInMeters = col_double(),
  verbatimElevation = col_double(),
  decimalLatitude = col_double(),
  decimalLongitude = col_double(),
  coordinateUncertaintyInMeters = col_double(),
  verbatimLatitude = col_double(),
  verbatimLongitude = col_double(),
  identificationID = col_double()
)
See spec(...) for full column specifications.
Warning message:
"4 parsing failures.
 row                           col           expected         actual                    file
1602 dcterms:bibliographicCitation 1/0/T/F/TRUE/FALSE R02783         'dangerous_species.csv'
1602 waterBody                     1/0/T/F/TRUE/FALSE not applicable 'dangerous_species.csv'
1602 islandGroup                   1/0/T/F/TRUE/FALSE not applicable 'dangerous_species.csv'
1602 island                        1/0/T/F/TRUE/FALSE not applicable 'dangerous_species.csv'
"Warning message in OGRSpatialRef(dsn, layer, morphFromESRI = morphFromESRI, dumpSRS = dumpSRS, :
"Discarded datum Geocentric_Datum_of_Australia_1994 in Proj4 definition: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs"
OGR data source with driver: ESRI Shapefile 
Source: "C:\Users\whitn\layer", layer: "parkres"
with 8501 features
It has 18 fields